﻿using MiniFox.Infrastructure;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace MiniFox.Platform.OAuth2.Models
{
    /// <summary>
    /// 
    /// </summary>
    [JsonObject]
    public class AuthorizeResult
    {
        Ticket _ticket;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ticket"></param>
        public AuthorizeResult(Ticket ticket)
        {
            _ticket = ticket;
        }
        /// <summary>
        /// 
        /// </summary>
        [JsonIgnore]
        public Ticket AuthTicket
        {
            get { return _ticket; }
        }
        /// <summary>
        /// 
        /// </summary>
        [JsonIgnore]
        public ExternalOpenAuthUser OpenAuthUser
        {
            get; set;
        }
        /// <summary>
        /// 
        /// </summary>
        [JsonProperty("authName")]
        public string AuthName
        {
            get 
            {
                if (this.OpenAuthUser == null)
                    return null;
                return this.OpenAuthUser.AuthName;
            }
        }
        /// <summary>
        /// 第三方认证状态
        /// </summary>
        [JsonProperty("status")]
        [JsonConverter(typeof(StringEnumConverter))]
        public DeviceAuthorizeStatus Status
        {
            get; set;
        }
    }
    /// <summary>
    /// 第三方认证状态枚举
    /// </summary>
    public enum DeviceAuthorizeStatus
    {
        /// <summary>
        /// 
        /// </summary>
        Default = 0,
        /// <summary>
        /// 
        /// </summary>
        Verified = 1,
        /// <summary>
        /// 
        /// </summary>
        Authorized = 2
    }
}
